package com.yyds.yygh.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yyds.yygh.common.result.Result;
import com.yyds.yygh.enums.OrderStatusEnum;
import com.yyds.yygh.model.order.OrderInfo;
import com.yyds.yygh.order.service.OrderInfoService;
import com.yyds.yygh.vo.order.OrderQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Api(tags = "订单接口")
@RequestMapping("/admin/order/orderInfo")
public class OrderController {

    @Autowired
    private OrderInfoService orderInfoService;

    @ApiOperation("分页列表")
    @GetMapping("/{page}/{limit}")
    public Result index(@PathVariable Long page,
                        @PathVariable Long limit,
                        OrderQueryVo orderQueryVo){
        Page<OrderInfo> params = new Page<>(page,limit);
        Page<OrderInfo> orderInfoPage = orderInfoService.selectPage(params, orderQueryVo);
        return Result.success(orderInfoPage);
    }
    @ApiOperation("获取订单状态")
    @GetMapping("/getStatusList")
    public Result getStatusList(){
        return Result.success(OrderStatusEnum.getStatusList());
    }
    @ApiOperation("获取订单")
    @GetMapping("/show/{id}")
    public Result show(@PathVariable Long id){
        Map<String, Object> map = orderInfoService.show(id);
        return Result.success(map);
    }
}
